//
//  main.m
//  宏
//
//  Created by 李煜 on 2023/4/7.
//https://my.oschina.net/iOScoderZhao/blog/916074
//__typeof__() https://blog.csdn.net/weixin_33961829/article/details/92300888

#define X_MIN(A,B) ((A) < (B) ? (A) : (B))
#define Y_MIN(A,B)  ({ __typeof__(A) __a = (A); __typeof__(B) __b = (B); __a < __b ? __a : __b; })

#import <Foundation/Foundation.h>

int main(int argc, const char * argv[]) {
  @autoreleasepool {

    float a = 1.0f;
    float b = X_MIN(a++, 1.5f);
    // => float b = ((a++) < (1.5f) ? (a++) : (1.5f))

    NSLog(@"\na: %f\nb: %f",a,b);

    float c = 1.0f;
    float d = Y_MIN(c++, 1.5f);
    NSLog(@"\nc: %f\nd: %f",c,d);
  }
  return 0;
}
